home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / startrek / trek73 / src / cmds4.c < prev    next >
C/C++ Source or Header  |  1995-04-11  |  9KB  |  273 lines

  1. /*
  2.  * TREK73: cmds4.c
  3.  *
  4.  * User Commands
  5.  *
  6.  * alterpntparams, play_dead, corbomite_bluff, surrender_ship,
  7.  * request_surrender, self_destruct, abort_self_destruct
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include "defines.h"
  13. #include "structs.h"
  14.  
  15. extern     int  defenseless;
  16. extern   char captain[];
  17. extern   char title[];
  18. extern     char science[];
  19. extern     char com[];
  20. extern     char nav[];
  21. extern     char helmsman[];
  22. extern     char engineer[];
  23. extern   char foerace[];
  24. extern   int  corbomite;
  25. extern   int  surrender;
  26. extern   int  surrenderp;
  27.  
  28. alterpntparams(sp)
  29. struct ship *sp;
  30. {
  31.     int temp;
  32.     char buf1[30];
  33.  
  34.     printf("\n%s:  Reset tubes, %s?\n",nav,title);
  35.     printf("%s:  [yes or no] ",captain);
  36.     if (Gets(buf1) == NULL)
  37.         return 0;
  38.     if ((buf1 != NULL) && (buf1[0] != 'n')) {
  39.         printf("   Set launch speed to [0-12] ");
  40.         if (Gets(buf1) == NULL)
  41.             return 0;
  42.         if (buf1 != NULL) {
  43.             temp = atoi(buf1);
  44.             if ((temp > -1) && (temp < 13))
  45.                 sp->t_lspeed = temp;
  46.         }
  47.         printf("   ...time delay to [0-10] ");
  48.         if (Gets(buf1) == NULL)
  49.             return 0;
  50.         if (buf1 != NULL) {
  51.             temp = atoi(buf1);
  52.             if ((temp > -1) && (temp < 11))
  53.                 sp->t_delay = temp;
  54.         }
  55.         printf("   ...proximity delay to [0-500] ");
  56.         if (Gets(buf1) == NULL)
  57.             return 0;
  58.         if (buf1 != NULL) {
  59.             temp = atoi(buf1);
  60.             if ((temp > -1) && (temp < 501))
  61.                 sp->t_prox = temp;
  62.         }
  63.     }
  64.     printf("%s:  Reset phasers, %s?\n",nav ,title);
  65.     printf("%s:  [yes or no] ",captain);
  66.     if (Gets(buf1) == NULL)
  67.         return 0;
  68.     if ((buf1 != NULL) && (buf1[0] != 'n')) {
  69.         printf("   Reset firing percentage to [0-100] ");
  70.         if (Gets(buf1) == NULL)
  71.             return 0;
  72.         if (buf1 != NULL) {
  73.             temp = atoi(buf1);
  74.             if ((temp > -1) && (temp < 101))
  75.                 sp->p_percent = temp;
  76.         }
  77.     }
  78.     return 0;
  79. }
  80.  
  81. play_dead(sp)
  82. struct ship *sp;
  83. {
  84.     
  85.     char buf1[30];
  86.     int  phaser_charge;
  87.     register int i;
  88.  
  89.     printf("%s:   Weapons officer, drop shields ...\n",captain);
  90.     if (defenseless) {
  91.         printf("%s:   %s, the %ss are not that stupid.",science, title,foerace);
  92.         return 0;
  93.     }
  94.     printf("   Transfer power to [engines or phasers]: ");
  95.     if (Gets(buf1) == NULL || *buf1 == NULL) {
  96.         printf("%s:   What?\n", nav);
  97.         return 0;
  98.     }
  99.     phaser_charge = -10.;
  100.     if (buf1[0] != 'e') {
  101.         phaser_charge = 10.;
  102.         if (buf1[0] != 'p') {
  103.             printf("%s:   What?\n", nav);
  104.             return 0;
  105.         }
  106.     }
  107.     for (i=0;i<4;i++) 
  108.         sp->shields[i].attemp_drain = 0.;
  109.     for (i=0;i<4;i++)
  110.         sp->phasers[i].drain = phaser_charge;
  111.     defenseless = 1;
  112.     return 0;
  113. }
  114.  
  115. corbomite_bluff(sp)
  116. struct ship *sp;
  117. {
  118.     
  119.     if (randm(2) == 1) {
  120.         printf("%s:   Open a hailing frequency, ship-to-ship.\n",captain);
  121.         printf("%s:  Hailing frequency open, %s.\n", com, title);
  122.         printf("%s:   This is the Captain of the %s.  Our respect for\n",captain, sp->name);
  123.         printf("   other life forms requires that we give you this warning--\n");
  124.         printf("   one critical item of information which has never been\n");
  125.         printf("   incorporated into the memory banks of any Earth ship.\n");
  126.         printf("   Since the early years of space exploration, Earth vessels\n");
  127.         printf("   have had incorporated into them a substance know as corbomite.\n");
  128.         if (!corbomite) {
  129.             printf("      It is a material and a device which prevents attack on\n");
  130.             printf("   us.  If any destructive energy touchs our vessel, a re-\n");
  131.             printf("   verse reaction of equal strength is created, destroying\n");
  132.             printf("   the attacker.  It may interest you to know that, since\n");
  133.             printf("   the initial use of corbomite for more than two of our\n");
  134.             printf("   centuries ago, no attacking vessel has survived the attempt.\n");
  135.             printf("   Death has little meaning to us.  If it has none to you,\n");
  136.             printf("   then attack us now.  We grow annoyed with your foolishness.\n");
  137.         }
  138.     } else {
  139.         printf("%s:   Open a special channel to Starfleet Command.\n",captain);
  140.         printf("%s:   Aye, %s.\n",com, title);
  141.         printf("%s:   Use Code 2.\n",captain);
  142.         printf("%s:   but, Captain, according to our last Starfleet\n", com);
  143.         printf("   Bulletin, the %ss have broken code 2.\n",foerace);
  144.         printf("%s:   That's an order, Lieutenant.  Code 2!\n",captain);
  145.         printf("%s:   Yes, Captain.  Code 2.\n", com);
  146.         printf("%s:   Message from %s to Starfleet Command, this sector.\n",captain,sp->name);
  147.         printf("   have inadvertantly encroached upon %s neutral zone,\n",foerace);
  148.         printf("   surrounded and under heavy %s attack.  Escape\n",foerace);
  149.         printf("   impossible.  Shields failing.  Will implement destruct\n");
  150.         printf("   order using corbomite device recently installed.\n");
  151.         if (!corbomite) {
  152.             printf("   This will result in the destruction of the %s and\n",sp->name);
  153.             printf("   all matter within a 200 megameter diameter and\n");
  154.             printf("   establish corresponding dead zone, all federation\n");
  155.             printf("   vessels will aviod this area for the next four solar\n");
  156.             printf("   years.  Explosion will take place in one minute.  %s,\n",captain);
  157.             printf("   commanding %s, out.\n",sp->name);
  158.         }
  159.     }
  160.     if (!corbomite) {
  161.         printf("      Mr. %s.  Stand by.\n", helmsman);
  162.         printf("%s:  Standing by.\n", helmsman);
  163.         corbomite = 1;
  164.     } else {
  165.         printf("\n%s:  I don't believe that they will fall for tha maneuver\n", science);
  166.         printf("   again, %s.\n",title);
  167.     }
  168.     return 0;
  169. }
  170.  
  171. surrender_ship(sp)
  172. struct ship *sp;
  173. {
  174.     printf("%s:   Lieutenant, open a channel to the %ss.\n", captain, foerace);
  175.     printf("%s:   Aye, %s.\n", com, title);
  176.     printf("%s:   This is Captain %s of the U. S. S. %s.  Will\n",captain,captain,sp->name);
  177.     printf("   you accept my unconditional surrender?\n");
  178.     if (surrender) {
  179.         printf("%s:  The %ss have already refused.\n",science, foerace);
  180.     } else {
  181.         if (foerace == "Romulan") {
  182.             printf("%s:  The %ss have not been know to have taken\n",science, foerace);
  183.             printf("   prisoners.\n");
  184.         }
  185.         surrender = 1;
  186.     }
  187.     return 0;
  188. }
  189.  
  190. request_surrender(sp)
  191. struct ship *sp;
  192. {
  193.     printf("%s:   Lieutenant, open a hailing frequency to the %ss.\n",captain,foerace);
  194.     printf("%s:  Aye, %s.\n", com, title);
  195.     printf("%s:  This is Captain %s of the U. S. S. %s.  I give you\n",captain, captain, sp->name);
  196.     printf("   one last chance to surrender before we resume our attack.\n");
  197.     if (surrenderp) {
  198.         printf("%s:   %s, our offer has already been refused.\n",science, title);
  199.     } else {
  200.         surrenderp = 1;
  201.     }
  202.     return 0;
  203. }
  204.  
  205. self_destruct(sp)
  206. struct ship *sp;
  207. {
  208.     printf("%s:   Lieutenant %s, tie in the bridge to the master\n",captain, com);
  209.     printf("   computer.\n");
  210.     if (sp->status & S_COMP) {
  211.         printf("%s:  Our computer is down.\n", science);
  212.         return 0;
  213.     }
  214.     printf("%s:   Aye, %s.\n",com, title);
  215.     printf("%s:  Computer.  Destruct sequence.  Are you ready to copy?\n",captain);
  216.     printf("Computer:  Working.\n");
  217.     printf("%s:  Computer, this is Captain %s of the U. S. S. %s.\n",captain,captain,sp->name);
  218.     printf("   destruct sequence one, code 1-1a.\n");
  219.     printf("Computer:  Voice and code verified and correct.\n");
  220.     printf("   Sequence one complete.\n");
  221.     printf("%s:  This is Commander %s, Science Officer.  Destruct\n", science, science);
  222.     printf("   sequence two, code 1-1a-2b.\n");
  223.     printf("Computer:  Voice and code verified and correct.  Sequence\n");
  224.     printf("   two complete.\n");
  225.     printf("%s:  This is Lieutenant Commander %s, Chief Engineering\n", engineer, engineer);
  226.     printf("   Officer of the U. S. S. %s.  Destruct sequence\n",sp->name);
  227.     printf("   number three, code 1-b2-b3.\n");
  228.     printf("Computer:  Voice and code verified and correct.\n");
  229.     printf("   Destruct sequence complete and engaged.  Awaiting final\n");
  230.     printf("   code for twenty second countdown.\n");
  231.     printf("%s:  Computer, this is Captain %s of the U. S. S. %s.\n",captain, captain, sp->name);
  232.     printf("   begin countdown, code 0-0-0, destruct 0.\n");
  233.     printf("Computer:  20 seconds to self-detruct.\n");
  234.     sp->delay = 9 * 20;
  235. return 0;
  236. }
  237.  
  238. abort_self_destruct(sp)
  239. struct ship *sp;
  240. {
  241.     printf("%s:   Computer, this is Captain %s of the U. S. S. %s.\n",captain,captain,sp->name);
  242.     printf("   Code 1-2-3 continuity abort destruct order, repeat:\n");
  243.     printf("   Code 1-2-3 continuity abort destruct order!\n");
  244.     if (sp->status & S_COMP) {
  245.         printf("%s:  Our computer is down.\n", science);
  246.         return 0;
  247.     }
  248.     if (sp->delay > 1000) {
  249.         printf("Computer:  Self-destruct sequence has not been\n");
  250.         printf("   initiated.\n");
  251.         return 0;
  252.     }
  253.     printf("Computer:   Self-destruct order ...");
  254.     fflush(stdout);
  255.     sleep(4);
  256.     if (sp->delay > 4 * 9) {
  257.         printf("aborted.  Destruct order aborted.\n");
  258.         sp->delay = 10000;
  259.         return 0;
  260.     } else {
  261.         printf("\n%s:  Too late, captain ...\n", science);
  262.         return 0;
  263.     }
  264. }
  265.  
  266. #ifdef AMIGA
  267. sleep (howlong)
  268. int howlong;
  269. {
  270.     Delay (50 * howlong);
  271. }
  272. #endif
  273.